#pragma once

// CFileListCtrl
namespace tools
{
	enum ListView;
}

struct FileInfo;

const int WM_ADD_FILE_TO_CHOSEN = WM_USER + 30;

class CFileListCtrl : public CListCtrl
{
	DECLARE_DYNAMIC(CFileListCtrl)

public:
	CFileListCtrl(CImageList* ilSmall,CImageList* ilLarge,
		bool showDirectory = true, bool isAddEnable = false);
	virtual ~CFileListCtrl();
	int Refresh (LPCTSTR pszPath);
	CString nowPath;
protected:
	CImageList* ilSmall;
	CImageList* ilLarge;
	bool columnOrder;
	int nowColumn;
	bool isShowDirectory,m_isAddFileEnable;
	tools::ListView listview;
	CMap<tools::ListView,tools::ListView,UINT,UINT> *viewToID;
	CArray<FileInfo*> m_directoryFileInfo;
	CArray<FileInfo*> m_filesInfo;

	BOOL AddDirectoryInfo(CFileFind& finder);
	BOOL AddFileInfo(CFileFind& finder);
	int AddDirectoryInfoToTree();
	int AddFileInfoToTree(int beginIndex);

	BOOL AddItem(FileInfo* info, int nIndex);
	void FreeItemMemory();

	static int CALLBACK CompareColumnItem (LPARAM lParam1, LPARAM lParam2,
		LPARAM lParamSort);
	static int CALLBACK CompareColumnItemRev (LPARAM lParam1, LPARAM lParam2,
		LPARAM lParamSort);

	virtual void PreSubclassWindow();
	afx_msg void OnDestroy();
	afx_msg void OnLvnGetdispinfo(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnLvnColumnclick(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnContextMenu(CWnd* /*pWnd*/, CPoint /*point*/);
	afx_msg void OnLabelfileFileLarge();
	afx_msg void OnLabelfileFileList();
	afx_msg void OnLabelfileFileReport();
	afx_msg void OnLabelfileFileSmall();
	afx_msg void OnLabelfileFileAdd();
	afx_msg void OnNMRClick(NMHDR *pNMHDR, LRESULT *pResult);	
	DECLARE_MESSAGE_MAP()
};

struct FileInfo
{
	CString	strFileName;
	ULONGLONG fileSize;
	CTime lastWriteTime;
	CString strPathName;
	bool isDirectory;
};


